package cn.edu.scau.cmi.linhongyu.singleton;

public class Marshal {
	private static Marshal[] marshal;
	private static int count = 0;
	private String name=null;
	
	private Marshal(String name) {
		this.setName(name);
	}
	
	public static Marshal getInstance(String name) {
		if(count==0) {
			marshal = new Marshal[10];
		}
		for(int i=0;i<count;i++) {
			if(name.equals(marshal[i].getName()))
				return marshal[i];
		}
		if(count<10&&!name.equals(null)) {
			marshal[count] = new Marshal(name);
			count++;
		}
		else
			return null;
		return marshal[count-1];
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public static int getCount() {
		return count;
	}
	
	public void setCount(int count) {
		Marshal.count = count;
	}
}
